package com.example.myapplication.base;

import android.app.Application;
import android.content.SharedPreferences;
import android.os.Build;

import com.example.myapplication.http.HttpHelp;
import com.example.myapplication.http.MemberData;

import java.util.HashMap;

public class App extends Application {
    private static App instance=null;
    public static App get() {
        return instance;
    }
    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;

    private MemberData memberData =null;
    @Override
    public void onCreate() {
        super.onCreate();
        instance=this;

        sharedPreferences=getSharedPreferences("android",MODE_PRIVATE);
        editor =sharedPreferences.edit();

        HashMap<String ,String > hashMap =new HashMap<>();
        hashMap.put("model", Build.MODEL);
        hashMap.put("token", sharedPreferences.getString("token", ""));
        HttpHelp.get().init(this,"http://192.168.8.61/api/",hashMap);

    }

    public SharedPreferences getSharedPreferences() {
        return sharedPreferences;
    }

    public void setSharedPreferences(SharedPreferences sharedPreferences) {
        this.sharedPreferences = sharedPreferences;
    }

    public SharedPreferences.Editor getEditor() {
        return editor;
    }

    public void setEditor(SharedPreferences.Editor editor) {
        this.editor = editor;
    }

    public static App getInstance() {
        return instance;
    }

    public static void setInstance(App instance) {
        App.instance = instance;
    }

    public MemberData getMemberData() {
        return memberData;
    }

    public void setMemberData(MemberData memberData) {
        this.memberData = memberData;
    }
}
